package com.zego.wawaji.ui.dialog.share;

import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zego.wawaji.R;
import com.zego.wawaji.base.module.ModuleMgr;
import com.zego.wawaji.third.share.ShareUtils;
import com.zego.wawaji.third.share.util.ShareEnum;
import com.zego.wawaji.ui.base.BaseDialogFragment;
import com.zego.wawaji.wawaji_client.App;

/**
 * 红包H5调用分享弹框
 * Created by Su on 2017/12/26.
 */
public class ShareRedDialog extends BaseDialogFragment implements View.OnClickListener {
    double heightRatio = 0;

    public ShareRedDialog() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        setContentView(R.layout.share_red_dialog);
        heightRatio = getContentView().getHeight() / ModuleMgr.getAppMgr().getScreenHeight();
        setDialogSizeRatio(1, heightRatio);
        setCanceledOnTouchOutside(true);
        settWindowAnimations(R.style.AnimDownInDownOut);
        setGravity(Gravity.BOTTOM);
        initView();
        return getContentView();
    }

    private void initView() {
        findViewById(R.id.share_weixin).setOnClickListener(this);
        findViewById(R.id.share_wx_circle).setOnClickListener(this);
        findViewById(R.id.share_link).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.share_weixin:
                ShareUtils.getInstance().shareData(App.getActivity(), ShareEnum.WEIXIN);
                break;

            case R.id.share_wx_circle:
                ShareUtils.getInstance().shareData(App.getActivity(), ShareEnum.WEIXIN_FRIENDS);
                break;

            case R.id.share_link:
                ShareUtils.getInstance().shareData(App.getActivity(), ShareEnum.COPY);
                break;
            default:
                break;
        }
    }
}